home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 April / macformat-049.iso / mac / Shareware Plus / Developers / dropg++ / usr / include / netccitt / pk.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  6.4 KB  |  208 lines  |  [TEXT/R*ch]

  1. /*
  2.  * Copyright (c) University of British Columbia, 1984
  3.  * Copyright (c) 1990, 1992, 1993
  4.  *    The Regents of the University of California.  All rights reserved.
  5.  *
  6.  * This code is derived from software contributed to Berkeley by
  7.  * the Laboratory for Computation Vision and the Computer Science Department
  8.  * of the University of British Columbia.
  9.  *
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions
  12.  * are met:
  13.  * 1. Redistributions of source code must retain the above copyright
  14.  *    notice, this list of conditions and the following disclaimer.
  15.  * 2. Redistributions in binary form must reproduce the above copyright
  16.  *    notice, this list of conditions and the following disclaimer in the
  17.  *    documentation and/or other materials provided with the distribution.
  18.  * 3. All advertising materials mentioning features or use of this software
  19.  *    must display the following acknowledgement:
  20.  *    This product includes software developed by the University of
  21.  *    California, Berkeley and its contributors.
  22.  * 4. Neither the name of the University nor the names of its contributors
  23.  *    may be used to endorse or promote products derived from this software
  24.  *    without specific prior written permission.
  25.  *
  26.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  27.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  30.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  31.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  32.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  33.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  34.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  35.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  36.  * SUCH DAMAGE.
  37.  *
  38.  *    @(#)pk.h    8.1 (Berkeley) 6/10/93
  39.  */
  40.  
  41. /*
  42.  *
  43.  *  X.25 Packet Level Definitions:
  44.  *
  45.  */
  46.  
  47. /* Packet type identifier field defintions. */
  48.  
  49. #define X25_CALL                         11
  50. #define X25_CALL_ACCEPTED                15   
  51. #define X25_CLEAR                        19
  52. #define X25_CLEAR_CONFIRM                23  
  53. #define X25_DATA                          0   
  54. #define X25_INTERRUPT                    35   
  55. #define X25_INTERRUPT_CONFIRM            39   
  56.  
  57. #define X25_RR                            1   
  58. #define X25_RNR                           5   
  59. #define X25_REJECT              9
  60. #define X25_RESET                        27 
  61. #define X25_RESET_CONFIRM                31   
  62. #define X25_DIAGNOSTIC            241
  63.  
  64. #define X25_RESTART                     251     
  65. #define X25_RESTART_CONFIRM        255 
  66.  
  67. /* Restart cause field definitions. */
  68.  
  69. #define X25_RESTART_DTE_ORIGINATED      0
  70. #define X25_RESTART_LOCAL_PROCEDURE_ERROR 1
  71. #define X25_RESTART_NETWORK_CONGESTION      3
  72. #define X25_RESTART_NETWORK_OPERATIONAL      7
  73. #define X25_RESTART_DTE_ORIGINATED2      128
  74.  
  75.  
  76. /* Miscellaneous definitions. */
  77.  
  78. #define DATA_PACKET_DESIGNATOR        0x01
  79. #define RR_OR_RNR_PACKET_DESIGNATOR    0x02
  80. #define RR_PACKET_DESIGNATOR        0x04
  81.  
  82. #define DEFAULT_WINDOW_SIZE        2
  83. #define MODULUS                8
  84.  
  85. #define ADDRLN                1
  86. #define MAXADDRLN            15
  87. #define FACILITIESLN            1
  88. #define MAXFACILITIESLN            10
  89. #define MAXUSERDATA            16
  90. #define MAXCALLINFOLN            1+15+1+10+16
  91.  
  92. #define PACKET_OK            0
  93. #define IGNORE_PACKET            1
  94. #define ERROR_PACKET            2
  95.  
  96. typedef char    bool;
  97. #define FALSE    0
  98. #define TRUE    1
  99.  
  100. /*
  101.  *  X.25 Packet format definitions
  102.  *  This will eventually have to be rewritten without reference
  103.  *  to bit fields, to be ansi C compliant and allignment safe.
  104.  */
  105.  
  106. typedef u_char octet;
  107.  
  108. struct x25_calladdr {
  109.     octet addrlens;
  110.     octet address_field[MAXADDRLN];
  111. };
  112.  
  113. struct x25_packet {
  114.     octet bits;
  115.     octet logical_channel_number;
  116.     octet packet_type;
  117.     octet packet_data;
  118. };
  119. #define packet_cause packet_data
  120.  
  121. struct data_packet {
  122.     octet bits;
  123. };
  124.  
  125. #define FACILITIES_REVERSE_CHARGE    0x1
  126. #define FACILITIES_THROUGHPUT        0x2
  127. #define FACILITIES_PACKETSIZE        0x42
  128. #define FACILITIES_WINDOWSIZE        0x43
  129.  
  130. #define PKHEADERLN    3
  131.  
  132. #define DP(xp)          (((struct data_packet *)&(xp) -> packet_type) -> bits)
  133. #define PS(xp)           X25GBITS(DP(xp), p_s)
  134. #define PR(xp)           X25GBITS(DP(xp), p_r)
  135. #define MBIT(xp)         X25GBITS(DP(xp), m_bit)
  136. #define SPR(xp, v)       X25SBITS(DP(xp), p_r, (v))
  137. #define SPS(xp, v)       X25SBITS(DP(xp), p_s, (v))
  138. #define SMBIT(xp, v)     X25SBITS(DP(xp), m_bit, (v))
  139.  
  140. #define LCN(xp)        (xp -> logical_channel_number + \
  141.     (X25GBITS(xp -> bits, lc_group_number) ? (X25GBITS(xp -> bits, lc_group_number) << 8) : 0))
  142. #define SET_LCN(xp, lcn) ((xp -> logical_channel_number = lcn), \
  143.     (X25SBITS(xp -> bits, lc_group_number, lcn > 255 ? lcn >> 8 : 0)))
  144.  
  145. struct mbuf *pk_template ();
  146.  
  147. /* Define X.25 packet level states. */
  148.  
  149. /* Call setup and clearing substates.  */
  150.  
  151. #define LISTEN           0
  152. #define READY            1
  153. #define RECEIVED_CALL    2
  154. #define SENT_CALL        3
  155. #define DATA_TRANSFER    4
  156. #define RECEIVED_CLEAR   5
  157. #define SENT_CLEAR       6
  158.  
  159. /* DTE states. */
  160.  
  161. #define DTE_WAITING        7
  162. #define DTE_RECEIVED_RESTART    8
  163. #define DTE_SENT_RESTART    9
  164. #define DTE_READY        0
  165.  
  166. /* Cleaning out ... */
  167.  
  168. #define LCN_ZOMBIE         10
  169.  
  170. #define MAXSTATES        11
  171.  
  172. /*
  173.  *  The following definitions are used in a switch statement after
  174.  *  determining the packet type.  These values are returned by the
  175.  *  pk_decode procedure. 
  176.  */
  177.  
  178. #define CALL             0 * MAXSTATES
  179. #define CALL_ACCEPTED    1 * MAXSTATES
  180. #define CLEAR            2 * MAXSTATES
  181. #define CLEAR_CONF       3 * MAXSTATES
  182. #define DATA             4 * MAXSTATES
  183. #define INTERRUPT        5 * MAXSTATES
  184. #define INTERRUPT_CONF   6 * MAXSTATES
  185. #define RR               7 * MAXSTATES
  186. #define RNR              8 * MAXSTATES
  187. #define RESET            9 * MAXSTATES
  188. #define RESET_CONF      10 * MAXSTATES
  189. #define RESTART         11 * MAXSTATES
  190. #define RESTART_CONF    12 * MAXSTATES
  191. #define REJECT          13 * MAXSTATES
  192. #define DIAG_TYPE       14 * MAXSTATES
  193. #define INVALID_PACKET  15 * MAXSTATES
  194. #define DELETE_PACKET    INVALID_PACKET
  195.  
  196. /*
  197.  * The following definitions are used by the restart procedures
  198.  * for noting wether the PLE is supposed to behave as DTE or DCE
  199.  * (essentially necessary for operation over LLC2)
  200.  */
  201. #define    DTE_DXERESOLVING    0x0001
  202. #define    DTE_PLAYDTE        0x0002
  203. #define    DTE_PLAYDCE        0x0004
  204. #define DTE_CONNECTPENDING    0x0010
  205. #define    DTE_PRETENDDTE        0x0020
  206.  
  207. #define MAXRESTARTCOLLISIONS    10
  208.